/**
 * @file Feature.h
 * @author 申飞麟
 * @brief 管理功能实现头文件
 * @date 2025.2.23
 */

#ifndef FEATURE_H
#define FEATURE_H

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

typedef struct List_CallName List_CallName; // 点名链表声明

typedef enum Status ///< 操作状态
{
    FEATURE_NOERROR = 0,    ///< 本次操作正常
    FEATURE_ERROR_FILE,     ///< 操作文件失败
    FEATURE_ERROR_NOFIND,   ///< 查询不到信息
    FEATURE_ERROR_NOMALLOC, ///< 内存分配失败
    FEATURE_EXIT            ///< 程序退出
} Status;

typedef struct __attribute__((packed)) Student_Information ///< 学生信息结构体
{
    char Name[13];  ///< 姓名
    char ID[12];    ///< 学号
    char Phone[12]; ///< 电话号码
    char Room[5];   ///< 宿舍号
} Student_Information;

typedef struct Student_Manage ///< 学生信息整体，包括信息和操作
{
    Student_Information Base;                                                             ///< 学生信息基类
    Status (*Find_Information)(FILE *, Student_Information *, const uint8_t);             ///< 查找信息函数指针
    Status (*Call_Name)(FILE *, List_CallName *, Student_Information *, uint8_t); ///< 点名函数指针
    Status (*Revise_Information)(FILE *, Student_Information *, uint8_t);                 ///< 修改信息指针
} Student_Manage;

typedef struct List_CallName ///< 点名专用链表
{
    int8_t *Name;   ///< 姓名
    List_CallName* Next; ///< 链表元素中的指针
} List_CallName;

Status Find_Information(FILE *Read_Fp, Student_Information *Information, const uint8_t Keyboard);
Status Revise_Information(FILE *Read_Fp, Student_Information *Information, uint8_t Keyboard);
Status Call_Name(FILE *Read_Fp, List_CallName *Example, Student_Information *Information, uint8_t Keyboard);
List_CallName *List_Init(void);
Status List_Add(List_CallName *Example, uint8_t *InputName);
Status Manage_Panel(void);
void List_Delete(List_CallName *Example);

#endif

